<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>示例7</title>
</head>
<body>
    <style type="text/css">
        .div1{
            width: 100px;
            height: 100px;
            background: red;
            margin-top: 20px;
        }
        button {
            padding: 10px 25px;
            border: none;
            background-color: #fff;
            border-radius: 5px;
        }
    </style>
    <div id="app">
       <button v-on:click='fn'>toggle</button>
         <!--v-on:可以简写成@-->
       <!--<button @click='fn'>toggle</button>-->
       <div class="div1" v-show='bol'></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script type="text/javascript">
        var vm=new Vue({
            el:'#app',
            data:{
                bol:false
            },
            methods:{
              fn : function() {
                   this.bol=!this.bol;
                }
            }
        });
    </script>
</body>
</html>